package com.common.core.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.common.core.domain.Result;
import com.common.core.domain.TableDataInfo;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class BaseController {
    public Result<Void> toResult(int rows){
        return rows>0 ? Result.success():Result.fail();
    }
    public Result<Void> toResult(boolean rows){
        return rows ? Result.success():Result.fail();
    }

    public TableDataInfo getTableData(List<?> list){
        if(CollectionUtil.isEmpty(list)){
            return TableDataInfo.empty();
        }
        return TableDataInfo.success(list,new PageInfo<>(list).getTotal());
    }
}
